<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport"
		content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no, viewport-fit=cover" />
    <title>医生说</title>
    <link rel="stylesheet" href="css/vant.css">
    <link rel="stylesheet" href="css/shareTopic.css">
    <link rel="stylesheet" href="css/conmask.css">
</head>

<body>
    <div id="app" v-cloak>
        <!-- 文章标题 开始 -->
        <div class="topicTitle">{{topic.topicName}}</div>
        <!-- 文章标题 结束 -->

        <!-- 文章内容 开始 -->
        <div v-html="topic.content"></div>
        <!-- 文章内容 结束 -->


        <!-- 商品展示 开始 -->
        <div class="productBox">
            <div class="boxTitle">
                下载值班长抢低价正品
            </div>
            <div class="procuctContent">
                <div class="productItem" v-for="item in wards">
                    <img :src="path+'product/product_'+item.product_id+'/'+ item.product_pic" class="proImg">
                    <div class="proName">{{item.product_name}}</div>
                    <div class="proInfo">{{item.product_title}}</div>
                    <div class="proPrice">活动专享价：<span>￥{{item.product_price}}.</span><span>00</span></div>
                </div>
            </div>
        </div>
        <!-- 商品展示 结束 -->

        <!-- 按钮 开始 -->
        <div class="topicBtn" @click="downHandle">
            下载APP查看
        </div>
        <div class="topicBtn1" @click="toShare">
            分享
        </div>
        <!-- 按钮 结束 -->

        <div class="downBox" v-if="showPop" @click="showPop=false">
            <img src="./img/downTip.png" alt="">
        </div>

        <div class="downBox" v-if="sharePop" @click="sharePop=false">
            <img class="shareImg" src="./img/shareImg.png" alt="">
        </div>

        <div class="mask" v-if="mask">
            <img src="img/load.gif">
        </div>
    </div>



    <script src="js/vue.min.js"></script>
    <script src="js/flex_ible/lib-flexible.js"></script>
    <script src="js/vant.min.js"></script>
    <script src="js/vue-lazyload.js"></script>
    <script src="js/url.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/ajax.js"></script>
    <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script>
        var ua = navigator.userAgent.toLowerCase();
        var isWeixin = ua.indexOf('micromessenger') != -1;
        if (!isWeixin) {
            // window.location.href = 'https://zbz-downlink.oss-cn-zhangjiakou.aliyuncs.com/com.ccclkj.clinic.wgt'
        }

        console.log(ua);
        console.log(isWeixin);

        Vue.use(VueLazyload);
        var vm = new Vue({
            el: '#app',
            data: {
                topicId: sessionStorage.getItem('topicId'),
                user_id: sessionStorage.getItem('userId'),
                shop_id: sessionStorage.getItem('shopId'),
                topic: '',
                wards: {},
                showPop: false,
                sharePop: false,
                mask: false,
            },
            created() {
                if (!this.topicId) {
                    window.location.replace("./newDown.html")
                }
                this.getData()
                this.getData1()
            },
            methods: {
                getData: function () {
                    var that = this;
                    ajax({
                        type: "post",
                        url: newUrl + "topic/getTopicById",
                        data: {
                            topicId: that.topicId,
                        },
                        dataType: 'json',
                        timeout: 10000,
                        contentType: "application/json",
                        success: function (res) {
                            var res = JSON.parse(res)
                            console.log(res)
                            var data = res.data
                            that.topic = data
                            console.log(that.topic)
                        },
                    })
                },
                getData1: function () {
                    var that = this;
                    ajax({
                        type: "post",
                        url: newUrl + "signIn/listWard",
                        data: {
                            user_id: that.user_id,
                            flag: 1,
                            type: 1
                        },
                        dataType: 'json',
                        timeout: 10000,
                        contentType: "application/json",
                        success: function (res) {
                            var res = JSON.parse(res)
                            console.log(res)
                            var data = res.data
                            that.wards = data.wards
                            console.log(that.wards)
                        },
                    })
                },
                downHandle: function () {

                    window.location.replace("newDown.html")
                    return;

                    const input = document.createElement('input');
                    document.body.appendChild(input);
                    input.setAttribute('value', 'https://zbz-downlink.oss-cn-zhangjiakou.aliyuncs.com/com.ccclkj.clinic.wgt');
                    input.select();
                    if (document.execCommand('copy')) {
                        document.execCommand('copy');
                        console.log(1222);
                        alert('已复制链接，请使用浏览器下载')
                    }
                    document.body.removeChild(input);

                    if (isWeixin) {
                        this.showPop = true
                    } else {
                        window.location.href = 'https://zbz-downlink.oss-cn-zhangjiakou.aliyuncs.com/com.ccclkj.clinic.wgt'
                    }
                },
                toShare: function () {
                    var _this = this;
                    _this.mask = true;
                    var title = _this.topic.topicName;
                    var dec = "这里有好文章，分享给你咯";
                    var url = location.href.split('#')[0];
                    ajax({
                        type: "post",
                        url: newUrl + "share/share",
                        data: {
                            url: url
                        },
                        dataType: 'json',
                        timeout: 10000,
                        contentType: "application/json",
                        success: function (data) {
                            var res = JSON.parse(data)
                            console.log(res)
                            _this.mask = false
                            var datas = res.data
                            wx.config({
                                debug: false,
                                appId: datas.appId,
                                timestamp: datas.timestamp,
                                nonceStr: datas.nonceStr,
                                signature: datas.sign,
                                jsApiList: [
                                    'checkJsApi',
                                    'updateAppMessageShareData',
                                    'updateTimelineShareData',
                                    'onMenuShareTimeline',
                                    'onMenuShareAppMessage'
                                ]
                            });
                            wx.ready(function () { //需在用户可能点击分享按钮前就先调用
                                _this.sharePop = true;
                                var img = path + 'topic/cover/' + _this.topic.cover;
                                var link_rrl =
                                    "https://www.ccclkj.cn/sharepage/index.html?user_id=" +
                                    _this.user_id + "&id=" + _this.topicId + "&flag=9&shopId=" + sessionStorage.shopId;
                                wx.updateAppMessageShareData({
                                    title: title, // 分享标题
                                    desc: dec, // 分享描述
                                    link: link_rrl, // 分享链接
                                    imgUrl: img, // 分享图标
                                    type: 'link', // 分享类型,music、video或link，不填默认为link
                                    success: function () {
                                        //$("body").remove(".thisMask");
                                        return false;
                                    }
                                })
                                wx.updateTimelineShareData({
                                    title: title, // 分享标题
                                    link: link_rrl, // 分享链接
                                    imgUrl: img, // 分享图标
                                    success: function () {
                                        //$("body").remove(".thisMask");
                                        return false;
                                    }
                                })
                            });
                        }
                    })
                },
            }
        })
    </script>

</body>

</html>